package com.atguigu.tingshu.order.pattern.factory;

import com.atguigu.tingshu.order.pattern.TradeStrategy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @author NJG
 * @version 1.0
 * @date 2025/8/5 16:01
 * @description
 */
@Component
public class TradeStrategyFactory {

    @Autowired
    private Map<String, TradeStrategy> tradeStrategyMap;


    /**
     * 根据商品类型获取对应的策略
     */
    public TradeStrategy getTradeStrategy(String itemType) {
        return tradeStrategyMap.get(itemType);
    }
}
